﻿using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
namespace INTEX.DataBase.Tools
{
    public partial class INTEXDBC
    {
        public DataSet QueryFSFARBEN(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = null;
            switch (option)
            {
                case 0:
                    or1.CommandText = "SELECT * FROM FSFARBEN WHERE  ROWNUM<2 ";
                    break;
                case 1:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSFARBEN  "
                    + " WHERE FSFMANDANT=:FSFMANDANT AND FSFART=:FSFART AND  FSFVAR=:FSFVAR AND FSFFARBE=:FSFFARBE ";
                    or1.Parameters.Add("FSFMANDANT", OracleType.NVarChar).Value = dwData["FSFMANDANT"].ToString();
                    or1.Parameters.Add("FSFART", OracleType.NVarChar).Value = dwData["FSFART"].ToString();
                    or1.Parameters.Add("FSFVAR", OracleType.NVarChar).Value = dwData["FSFVAR"].ToString();
                    or1.Parameters.Add("FSFFARBE", OracleType.NVarChar).Value = dwData["FSFFARBE"].ToString();
                    break;
                case 2:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSFARBEN  "
                    + " WHERE FSFMANDANT=:FSFMANDANT AND FSFART=:FSFART AND  FSFVAR=:FSFVAR ";
                    or1.Parameters.Add("FSFMANDANT", OracleType.NVarChar).Value = dwData["FSFMANDANT"].ToString();
                    or1.Parameters.Add("FSFART", OracleType.NVarChar).Value = dwData["FSFART"].ToString();
                    or1.Parameters.Add("FSFVAR", OracleType.NVarChar).Value = dwData["FSFVAR"].ToString();
                    break;
                case 3:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSFARBEN  "
                    + " WHERE FSFMANDANT=:FSFMANDANT AND FSFART=:FSFART ";
                    or1.Parameters.Add("FSFMANDANT", OracleType.NVarChar).Value = dwData["FSFMANDANT"].ToString();
                    or1.Parameters.Add("FSFART", OracleType.NVarChar).Value = dwData["FSFART"].ToString();
                    break;
                case 4:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT FSFFARBE,FSFABEZ  FROM FSFARBEN  "
                    + " WHERE FSFMANDANT=:FSFMANDANT AND FSFART=:FSFART ";
                    or1.Parameters.Add("FSFMANDANT", OracleType.NVarChar).Value = dwData["FSFMANDANT"].ToString();
                    or1.Parameters.Add("FSFART", OracleType.NVarChar).Value = dwData["FSFART"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);

            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "FSFARBEN";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
    }
}
